#include "track.h"

Track::Track(const unsigned long& aID):
    id(aID), name(cUNNAMED), pointList()
{}

Track::~Track()
{
    name.clear();
    pointList.clear();
}

void Track::ClearTrack(void)
{
    name = cUNNAMED;
    pointList.clear();
}

bool Track::SetName(const QString& aName)
{
    if(!aName.isEmpty())
    {
        name = aName;
        return true;
    }
    else
        return false;
}

QString Track::GetName(void) const
{
    return name;
}

void Track::SetID(const unsigned long& aID)
{
    id = aID;
}

unsigned long Track::GetID(void) const
{
    return id;
}

void Track::AddPoint(const TrackPoint& aTrackPoint)
{
    pointList.push_back(aTrackPoint);
}

void Track::AddPoint(const QDateTime& aDateTime, const GeoCoordinates& aCoord)
{
    pointList.push_back(TrackPoint(aDateTime, aCoord));
}

void Track::AddPoint(const QDateTime& aDateTime, const double& aLatitude, const double& aLongitude)
{
    pointList.push_back(TrackPoint(aDateTime, GeoCoordinates(aLatitude, aLongitude)));
}

int Track::GetPointCount(void) const
{
    return pointList.size();
}

bool Track::GetPoint(TrackPoint *aTrackPoint, const int &aNumber) const
{
    if(aNumber >= 0 && aNumber < pointList.size())
    {
        aTrackPoint->SetCoordinates(pointList[aNumber].GetCoordinates());
        aTrackPoint->SetDateTime(pointList[aNumber].GetDateTime());
        return true;
    }
    else
        return false;
}

QList <TrackPoint> Track::GetPointList(void) const
{
    return pointList;
}
